﻿
@section Scripts{
    <script src="~/Scripts/plugins/bootstrap.min.js"></script>
    <script src="~/Scripts/plugins/bootstrap-table/bootstrap-table.min.js"></script>
    <script src="~/Scripts/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>

    <script src="~/Scripts/plugins/layer/layer.min.js"></script>
    <script src="~/Scripts/sys/lib/common_raw.js"></script>


<link rel="stylesheet" type="text/css" href="/css/libs/ns-default.css"  />
<link rel="stylesheet" type="text/css" href="/css/libs/ns-style-attached.css"   />
 
<script src="/js/modernizr.custom.js" ></script>
<script src="/js/snap.svg-min.js"  ></script>
<script src="/js/classie.js" ></script>
<script src="/js/notificationFx.js"  ></script>


    <script type="text/javascript">
        function BindInfo() {

            common.invokeApi(
                "POST", '/getAgencyUsers.html', { keyword: $("#keyword").val(), state: $("#state").val(), aliid: $('#aliid').val(), aliid: $('#aliid').val(), oneagen: $('#oneagen').val(), twoagen: $('#twoagen').val() },
                 function () { },
                  function (data) {
                      if (data.State) {
                          $('#arInfo').html("");
                          obj.maxCount = 1;
                          obj.maxCount = data.Datas.Total;
                          for (var i = 0; i < data.Datas.Rows.length; i++) {
                              var item = data.Datas.Rows[i];

                              var html = "<div class=\"col-lg-3 col-md-6 col-sm-6 col-xs-12\"><div class=\"main-box clearfix profile-box-contact\"><div class=\"main-box-body clearfix\"><div class=\"profile-box-header blue-bg clearfix\" style=\"padding: 10px 10px;\"><img style=\"width: 50px; height:50px\" src=\"http://img.bitscn.com/upimg/allimg/c160120/1453262W253120-12J05.jpg\" alt=\"\" class=\"profile-img img-responsive\">";

                              if (item.onthe_superior> 0)
                              {
                                  html +=
                                 '<span class="label label-warning   pull-right">二级 ' +item.onthe_superior_commission + '%</span>';
                              }

                              
                              if (item.superior != 0)
                              {

                              
                              html +=
                                  '<span class="label label-danger   pull-right">一级 ' + item.superior_commission + '% </span>';
                              }

                                  html+= "<h2>" + item.username + "</h2><div class=\"job-position\">联盟账号：" + item.alimamaid + "</div><ul class=\"contact-details\"><li><i class=\"fa fa-home\"></i>" + item.site_pid + "</li><li><i class=\"fa fa-weixin\"></i>" + item.wechat_pid + "</li><li><i class=\"fa fa-qq\"></i>" + item.qq_pid + "</li></ul></div>";

                              html += "<div class=\"profile-box-footer clearfix\" style=\"padding-top:0px;padding-bottom:0px;\">";
                              html += "<a href=\"javascript:Edit(" + item.id + ",'" + item.username + "')\" style=\"width:25%\"><span class=\"label\">编辑</span></a>";
                             // html += "<a href=\"javascript:Set(" + item.id + ",'" + item.username + "')\" style=\"width:25%\"><span class=\"label\">代理编辑</span></a>";
                              html += "<a name='updatep' href=\"javascript:UpdatePid('" + item.username + "','" + item.alimamaid + "')\" style=\"width:25%\"><span class=\"label\">更新pid</span></a>";

                              html += "<a   href=\"/editAgencyRobot.html?ua=" + item.username + " \" style=\"width:25%\"><span class=\"label\">新增绑定</span></a></div>";



                              html += "</div></div></div>";


                              $('#arInfo').append(html);
                          }

                      }

                  },
                  function (data) {
                      common.msg(data.Message, 2, function () { });
                  },
                  function () { }
            )
        }

    function list() {
        obj.CurrentIndex++;
        common.invokeApi(
              "POST",
              "/getAgencyUsers.html",
                { offset: obj.CurrentIndex, keyword: $("#keyword").val(), state: $("#state").val(), aliid: $('#aliid').val(), aliid: $('#aliid').val(), oneagen: $('#oneagen').val(), twoagen: $('#twoagen').val() },
              function () { },
              function (data) {
                  if (data.State) {


                      obj.maxCount = data.Datas.Total;
                      for (var i = 0; i < data.Datas.Rows.length; i++) {
                          var item = data.Datas.Rows[i];

                          var html = "<div class=\"col-lg-3 col-md-6 col-sm-6 col-xs-12\"><div class=\"main-box clearfix profile-box-contact\"><div class=\"main-box-body clearfix\"><div class=\"profile-box-header blue-bg clearfix\" style=\"padding: 10px 10px;\"><img style=\"width: 50px; height:50px\" src=\"http://img.bitscn.com/upimg/allimg/c160120/1453262W253120-12J05.jpg\" alt=\"\" class=\"profile-img img-responsive\">";


                          if (item.onthe_superior > 0) {
                              html +=
                             '<span class="label label-warning   pull-right">二级 ' + item.onthe_superior_commission + '%</span>';
                          }


                          if (item.superior != 0) {


                              html +=
                                  '<span class="label label-danger   pull-right">一级 ' + item.superior_commission + '% </span>';
                          }



                          html+= "<h2>" + item.username + "</h2><div class=\"job-position\">联盟账号：" + item.alimamaid + "</div><ul class=\"contact-details\"><li><i class=\"fa fa-home\"></i>" + item.site_pid + "</li><li><i class=\"fa fa-weixin\"></i>" + item.wechatpid + "</li><li><i class=\"fa fa-qq\"></i>" + item.qq_pid + "</li></ul></div>";

                          html += "<div class=\"profile-box-footer clearfix\" style=\"padding-top:0px;padding-bottom:0px;\">";
                          html += "<a href=\"javascript:Edit(" + item.id + ",'" + item.username + "')\" style=\"width:25%\"><span class=\"label\">编辑</span></a>";
                          //html += "<a href=\"javascript:Set(" + item.id + ",'" + item.username + "')\" style=\"width:25%\"><span class=\"label\">代理编辑</span></a>";
                          html += "<a href=\"javascript:UpdatePid('" + item.username + "','" + item.alimama_id + "')\" style=\"width:25%\"><span class=\"label\">更新pid</span></a> ";

                          html += "<a  href=\"/editAgencyRobot.html?ua=" + item.username + "\" style=\"width:25%\"><span class=\"label\">新增绑定</span></a></div>";


                          html += "</div></div></div>";
                          $('#arInfo').append(html);
                      }

                  }
              },
              function (data) {
                  common.msg(data.Message, 2, function () { });
              },
              function () { }
              );

    }



    $(document).ready(function () {

        BindInfo();
        $("#search").bind("click", function () {
            var load_index3 = layer.load(0, { shade: 0.6 });

            BindInfo();
            layer.close(load_index3);
        });
        $("#state").change(function () {
            var load_index2 = layer.load(0, { shade: 0.6 });
            BindInfo();
            layer.close(load_index2);
        });

        $("#btnAdd").click(function () {
            window.location.href = '/editAgencyUser.html';
        });
    });


    var parengPanel;

    function Edit(id, username) {
        window.location.href = '/editAgencyUser.html?id=' + id;
    }
    //function Set(id, username) {
    //    window.location.href = '/setAgencyUser.html?id=' + id;
    //}
 
    function UpdatePid(username,mmid)
    {
        if (mmid == 'null' || mmid.length <= 0)
        {
            common.msg("请先绑定联盟账号！", 2, function () { });
            return false;
        }
        common.invokeApi(
          "POST", '/UpdatePid.html?accountName=' + username + '&mmId=' + mmid, null,
           function () {
               // create the notification
               var notification = new NotificationFx({
                   message: '<span   class="fa fa-calendar fa-3x pull-left"></span><p style="width:200px">' + username + ' 已经提交更新  </p>',
                   layout: 'growl',//'attached',
                   effect: 'bouncyflip',
                   type: 'success', // notice, warning or error
                    onClose: function () {
                       bttnBouncyflip.disabled = true;
                   }
               });

               // show the notification
               notification.show();
           },
            function (data) {
                if (data.State) {
                    common.msg("成功下达更新pid命令，稍后刷新页面！",1, function () { });
                }
            },
            function (data) {
                common.msg(data.Message, 2, function () { });
            },
            function () { }
      )
    }


    var obj = {};
    obj.CurrentIndex = 1;
    obj.SearchWord = "";
    obj.cid = "0";
    obj.maxCount = 0;
    document.onkeydown = function () {
        if (event.keyCode == 13) {

            //if ($.trim($("#search").val()) != "") {
            //    obj.SearchWord = $.trim($("#search").val());
            //    obj.cid = 0;
            //    obj.CurrentIndex = 1;
            //   // $("#shopclass").find("span").removeClass("label-large").removeClass("label-danger");
            //   // $("#productlist").html("");
            list();
            //}
        }
    }

    function scrollFn() {
        obj.CurrentIndex = obj.CurrentIndex++;
        var pageHeight = Math.max(document.body.scrollHeight, document.body.offsetHeight);
        var viewportHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight || 0;
        var scrollHeight = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
        if (pageHeight - viewportHeight - scrollHeight < 1) {
            var totalPages = Math.ceil(obj.maxCount / 20);

            if ((obj.CurrentIndex + 1) > totalPages) {
                return;
            }
            list();
            //alert(11);
        }
    }
    window.addEventListener("scroll", scrollFn);





</script>

}
<input type="hidden" value="1" id="handle_status" />
<input type="hidden" value="1" id="maxCount" />
 

<div class="row">
    <div class="row">
        <div class="col-lg-12">
            <ol class="breadcrumb">
                <li><a href="#">首页</a></li>
                <li class="active"><span>代理管理</span></li>
            </ol>
            <div class="clearfix">
                <h1 class="pull-left">代理信息列表</h1>
                <div class="pull-right top-page-ui">
                    <a href="/EditAgencyUser.html" class="btn btn-primary pull-right">
                        <i class="fa fa-plus-circle fa-lg"></i> 新增账户
                    </a>
                </div>
            </div>
        </div>
    </div>
    <div class="row col-lg-12">
        <div class="row">
            <div class="col-lg-12">
                <div class="main-box">
                    <header class="main-box-header clearfix">
                        <h2>搜索条件</h2>
                    </header>
                    <div class="main-box-body clearfix">
                        <form class="form-inline" role="form">
                            <div class="form-group">
                                <select class="form-control" name="" id="state">
                                    <option value="-1">账号状态</option>
                                    <option value="1">启用</option>
                                    <option value="0">禁用</option>
                                </select>
                            </div>
                            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                            <div class="form-group">
                                <label class="sr-only" for="aliid">联盟账号id</label>
                                <input type="text" class="form-control" id="aliid" placeholder="联盟账号id">
                            </div>
                            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                            <div class="form-group">
                                <label class="sr-only" for="oneagen">一级代理</label>
                                <input type="text" class="form-control" id="oneagen"  placeholder="一级代理">
                            </div>
                            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                            <div class="form-group">
                                <label class="sr-only" for="twoagen">二级代理</label>
                                <input type="text" class="form-control" id="twoagen" placeholder="二级代理">
                            </div>
                            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                            <div class="input-group">
                                <span class="input-group-btn">
                                    <input type="text" placeholder="搜索账号、昵称、备注、PID" style="width:250px" class="input-s form-control" id="keyword" name="keyword">
                                    <button type="button" class="btn btn-s btn-primary" id="search">搜索</button>
                                </span>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="row" style="opacity: 1;">
    <div class="col-lg-12">
        <div class="row" id="arInfo">

        </div>
    </div>
</div>


